$(document).ready(function() {
	$(".search-voc-list-switch-languages").button ({
		icons: {
			primary: "ui-icon-arrow-2-e-w"
		},
		text: false
	});
	$(".search-voc-list-switch-languages").click (function(e){
		var tmp = $('#searchForm-fromLang').val();
		$('#searchForm-fromLang').val($('#searchForm-toLang').val());
		$('#searchForm-toLang').val(tmp);
		e.stopPropagation();
		return false;
	});
	function validateCreateListName() {
		var text = $("#name").val();
		if (!text.length) {
			$("#name").addClass('field-error');
		} else {
			$("#name").removeClass('field-error');
		} // if
	} // validateCreateListName
	$("#name").bind('keyup cut paste blur focus', function(e) {
		validateCreateListName();
	});
	$(".save-submit").click(function(e){
		var text = $("#name").val();
		if (!text.length) {
			alert ('Please fill the "Name" field');
			e.preventDefault();
			e.stopPropagation ();
			return false;
		} // if
	});
	validateCreateListName();
	$(".ln-voc-introduction").click (function() {
		$(".ln-menu-item-selected").removeClass("ln-menu-item-selected");
		$(this).addClass("ln-menu-item-selected");
		$(".voc-tabs").hide();
		$(".tabs-introduction").show();
	});
	$(".ln-voc-fav-lists").click (function() {
		$(".ln-menu-item-selected").removeClass("ln-menu-item-selected");
		$(this).addClass("ln-menu-item-selected");
		$(".voc-tabs").hide();
		$(".tabs-fav-lists").show();
	});
	$(".ln-voc-manage-lists").click (function() {
		$(".ln-menu-item-selected").removeClass("ln-menu-item-selected");
		$(this).addClass("ln-menu-item-selected");
		$(".voc-tabs").hide();
		$(".tabs-manage-lists").show();
	});
	$(".ln-voc-create").click (function() {
		$(".ln-menu-item-selected").removeClass("ln-menu-item-selected");
		$(this).addClass("ln-menu-item-selected");
		$(".voc-tabs").hide();
		$(".tabs-create").show();
	});
	$(".ln-voc-find").click (function() {
		$(".ln-menu-item-selected").removeClass("ln-menu-item-selected");
		$(this).addClass("ln-menu-item-selected");
		$(".voc-tabs").hide();
		$(".tabs-find").show();
	});
	if (loginOkay != "1") {
		$('.vocabulary-list').attr("disabled", "disabled");
		$('.save-submit').click (function (e){
			alert ("Please first login");
			e.preventDefault();
			e.stopPropagation();
			return false;
		});
	} // if
	$('.vocabulary-list').val ("Please enter words on separate lines.\n" +
		"\n" +
		"Examples:\n" +
		"from language = to language\n" +
		"word1 = meaning of word1\n" +
		"phrase one = meaning of phrase one.\n");
});

function clearNewVocabulary () {
	$('#name, #tags, .vocabulary-list').val ("");
} // clearNewVocabulary
